+2007-01-14 Matthias Clasen <mclasen@redhat.com>
+
+ * gtk/gtkicontheme.c (theme_lookup_icon): When finding a matching
+ non-scalable dir, keep going and look for a closer match.
+ (#395830, Luca Ferretti)
+
2007-01-14 Christian Persch <chpe@svn.gnome.org>
* gtk/gtkclipboard.c: (gtk_clipboard_set_text),
char *file;
int min_difference, difference;
BuiltinIcon *closest_builtin = NULL;
- gboolean smaller, has_larger;
+ gboolean smaller, has_larger, match;
IconSuffix suffix;
min_difference = G_MAXINT;
min_dir = NULL;
has_larger = FALSE;
+ match = FALSE;
/* Builtin icons are logically part of the default theme and
* are searched before other subdirectories of the default theme.
if (difference == 0)
{
- min_dir = dir;
- break;
- }
-
- if (!has_larger)
- {
- if (difference < min_difference || smaller)
- {
- min_difference = difference;
- min_dir = dir;
- closest_builtin = NULL;
- has_larger = smaller;
- }
- }
- else
- {
- if (difference < min_difference && smaller)
- {
- min_difference = difference;
- min_dir = dir;
- closest_builtin = NULL;
- }
+ if (dir->type == ICON_THEME_DIR_SCALABLE)
+ {
+ /* don't pick scalable if we already found
+ * a matching non-scalable dir
+ */
+ if (!match)
+ {
+ min_dir = dir;
+ break;
+ }
+ }
+ else
+ {
+ /* for a matching non-scalable dir keep
+ * going and look for a closer match
+ */
+ difference = abs (size - dir->size);
+ if (!match || difference < min_difference)
+ {
+ match = TRUE;
+ min_difference = difference;
+ min_dir = dir;
+ }
+ if (difference == 0)
+ break;
+ }
+ }
+
+ if (!match)
+ {
+ if (!has_larger)
+ {
+ if (difference < min_difference || smaller)
+ {
+ min_difference = difference;
+ min_dir = dir;
+ has_larger = smaller;
+ }
+ }
+ else
+ {
+ if (difference < min_difference && smaller)
+ {
+ min_difference = difference;
+ min_dir = dir;
+ }
+ }
}
-
- }
+ }
l = l->next;
}
}
- if (closest_builtin)
- return icon_info_new_builtin (closest_builtin);
-
if (min_dir)
{
GtkIconInfo *icon_info = icon_info_new ();
return icon_info;
}
-
+
+ if (closest_builtin)
+ return icon_info_new_builtin (closest_builtin);
+
return NULL;
}